package edu.thu.studio.ormdesigner.editor.editpart;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;

import edu.thu.studio.ormdesigner.editor.figure.ColumnFigure;
import edu.thu.studio.ormdesigner.model.orm.table.Column;

public class ColumnEditPart extends AbstractModelEditPart {
    
    @Override
    protected IFigure createFigure() {
        ColumnFigure figure = new ColumnFigure();
        return figure;
    }
    
    public void refreshColumns() {
        Column column = (Column) this.getModel();
        ((ColumnFigure) figure).addColumn(column);
        
        NodeEditPart parent = (NodeEditPart) this.getParent();
        parent.getContentPane().add(figure);
    }
    
    @Override
    protected void createEditPolicies() {
    }
    
    @Override
    public EditPart getTargetEditPart(Request request) {
        EditPart editPart = super.getTargetEditPart(request);
        if (editPart != null) {
            return editPart.getParent();
        }
        return null;
    }
    
    @Override
    public void performRequest(Request request) {
        this.getParent().performRequest(request);
    }
    
}
